using System.Windows.Controls;
using System.Windows;
using System.Windows.Media;
using System.Windows.Data;
using System.Windows.Shapes;

namespace PropertyExpression.PresentationCode
{
    public static partial class GridExtensions
    {
        public static Grid ColumnDefinitions(this Grid it, params ColumnDefinition[] values)
        {
            it.Add(_ => _.ColumnDefinitions, values);
            return it;
        }

        public static Grid Children(this Grid it, params UIElement[] values)
        {
            it.Add(_ => _.Children, values);
            return it;
        }

        public static Grid Nested(this Grid it, params UIElement[] values)
        {
            return it.Children(values);
        }

        public static Grid RowDefinitions(this Grid it, params RowDefinition[] values)
        {
            it.Add(_ => _.RowDefinitions, values);
            return it;
        }
    }

    public static partial class StyleExtensions
    {
        public static Style Setters(this Style it, params SetterBase[] values)
        {
            it.Add(_ => _.Setters, values);
            return it;
        }

        public static Style Triggers(this Style it, params TriggerBase[] values)
        {
            it.Add(_ => _.Triggers, values);
            return it;
        }

        public static Style TargetType<T>(this Style it, IPropertyProvider<T> value)
        {
            return it.TargetType(typeof(T));
        }
    }

    public static partial class SetterExtensions
    {
        public static Setter Property(this Setter it, IPropertyValue propertyValue)
        {
            it.Property = propertyValue.DependencyProperty;
            it.Value = propertyValue.Value;
            return it;
        }

        public static Setter TargetName<T>(this Setter it, IElement<T> value)
        {
            return it.TargetName(value.Name);
        }
    }

    public static partial class TriggerExtensions
    {
        public static Trigger Property(this Trigger it, IPropertyValue propertyValue)
        {
            it.Property = propertyValue.DependencyProperty;
            it.Value = propertyValue.Value;
            return it;
        }

        public static Trigger Setters(this Trigger it, params SetterBase[] values)
        {
            it.Add(_ => _.Setters, values);
            return it;
        }
    }

    public static partial class DataTriggerExtensions
    {
        public static DataTrigger Setters(this DataTrigger it, params SetterBase[] values)
        {
            it.Add(_ => _.Setters, values);
            return it;
        }

        public static DataTrigger Nested(this DataTrigger it, params SetterBase[] values)
        {
            return it.Setters(values);
        }
    }

    public static partial class LinearGradientBrushExtensions
    {
        public static LinearGradientBrush GradientStops(this LinearGradientBrush it, params GradientStop[] values)
        {
            it.Add(_ => _.GradientStops, values);
            return it;
        }
    }

    public static partial class BindingExtensions
    {
        public static Binding Path(this Binding it, string value)
        {
            return it.Path(new PropertyPath(value));
        }
    }

    public static partial class GradientStopExtensions
    {
        public static GradientStop Color(this GradientStop it, string value)
        {
            return it.Color((Color)ColorConverter.ConvertFromString(value));
        }
    }

    public static partial class GridAttachedPropertyExtensions
    {
        public static T Grid_Position<T>(this T it, int row, int column)
            where T : UIElement
        {
            return it.Grid_Row(row).Grid_Column(column);
        }
    }

    public static partial class DataTemplateExtensions
    {
        public static DataTemplate Nested(this DataTemplate it, IElementBase elementBase)
        {
            return it.InternalNested(elementBase);
        }

        public static DataTemplate Triggers(this DataTemplate it, params TriggerBase[] values)
        {
            it.Add(_ => _.Triggers, values);
            return it;
        }
    }

    public static partial class ControlTemplateExtensions
    {
        public static ControlTemplate Nested(
            this ControlTemplate it, IElementBase elementBase)
        {
            return it.InternalNested(elementBase);
        }
    }

    public static partial class PathExtensions2
    {
        public static IElement<Path> Data(
            this IElement<Path> it, string value)
        {
            return it.Data(Geometry.Parse(value));
        }
    }
}